<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" >

<head>
	<title>次元档案馆藏一体化平台</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" type="text/css" href="/assets/css/index.css">
	<link rel="stylesheet" type="text/css" href="/assets/css/css.css">
	<link rel="stylesheet" type="text/css" href="/assets/css/reset.css">
	<script type="text/javascript" src='/assets/js/jquery-3.5.1.min.js'></script>
</head>

<body >
	<div class="box">
		<div class="index_top">
			<div class="index_top_left">
				<a href="/index" class="index_logo"></a>
			</div>
			<div class="index_top_right">
				<div class="index_top_right_list">
					<ul>
						<li class="top_active index_top_right_list_li"><a onclick="setCurrentUrl(this)" href="/first" target="iframe_a" >首页</a></li>

						<li shiro:hasPermission="mangers"  class="index_top_right_list_li"><a href="/manger" onclick="setCurrentUrl(this)" target="iframe_a">档案管理</a></li>

						<li shiro:hasPermission="authoritys" class="index_top_right_list_li"><a href="/authority" onclick="setCurrentUrl(this)" target="iframe_a">系统配置</a></li>

						<li class="index_top_right_list_li"><a onclick="sessionStorage.clear()" href="/passport/logout">退出系统</a></li>
					</ul>
				</div>
			</div>
			<div class="index_top_portrait" style="float: right;">
				<div class="container">
					<div class="circle">
						<img src="/assets/images/default.jpeg" alt="">
					</div>
					<div class="name"></div>
				</div>
			</div>
		</div>
		<iframe class="index_box" name="iframe_a" id="iframe_a" frameborder="0" src="/first"></iframe>
	</div>

</body>

<script>
	$('.index_top_right_list_li').click(function () {
		$('.index_top_right_list_li').removeClass("top_active");
		$(this).addClass("top_active");
	})
</script>
<script>
	let CURRENT_URL = sessionStorage.getItem("CURRENT_URL") ? sessionStorage.getItem("CURRENT_URL") : "/first",
	CURRENT_PAGE_URL = sessionStorage.getItem("CURRENT_PAGE_URL") ? sessionStorage.getItem("CURRENT_PAGE_URL") : null
	$(".index_top_portrait .name").text(sessionStorage.getItem("name"));

	function setCurrentUrl(el) {
		// console.log(el.href);
		sessionStorage.setItem("CURRENT_URL", el.href)
	}
	var iframe_a = document.getElementById("iframe_a");
	iframe_a.src = CURRENT_URL ? CURRENT_URL : "/first";
	if (!CURRENT_URL.match("/first")) {
		let $menu = $('.index_top_right_list_li');
		$menu.eq(0).removeClass("top_active");
		for (let index = 0; index < $menu.length; index++) {
			const element = $menu.eq(index);
			let str = element.children().eq(0).attr("href");
			if (!!CURRENT_URL.match(str)) {
				$menu.eq(index).addClass("top_active");
			}
		}
	}
</script>
</html>